﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Pg.BioMedics.SDR.Data;
using Pg.BioMedics.SDR.Entities;
using Pg.BioMedics.SDR.Entities.Codes;

namespace Pg.BioMedics.SDR.Services
{
    /// <summary>
    /// As interface for a service holding logic related with users managment
    /// </summary>    
    public interface IManagementService : IService
    {
        /// <summary>
        /// Registers a new person account in the system. Roles are not assigned
        /// to the person
        /// </summary>
        /// <param name="person">Not saved person account</param>
        /// <returns>Saved person account instance</returns>        
        Person Register(Person person);

        /// <summary>
        /// Registers a new person in the system. This method assigns a set  
        /// of specified roles to the newly registered person.
        /// </summary>
        /// <param name="person">Not saved person account</param>
        /// <param name="playedRoles">List of played roles</param>
        /// <returns>Registered person</returns>
        Person Register(Person person, params PlayedRole[] playedRoles);

        /// <summary>
        /// Updates person account definition stored in the system
        /// </summary>
        /// <param name="person">Modified person account</param>
        void Update(Person person);

        /// <summary>
        /// Updates person account definition stored in the database. List of 
        /// played roles is compared with roles stored in the database
        /// </summary>
        /// <param name="person">Saved person instance</param>
        /// <param name="playedRoles">Modified list of played roles</param>
        void Update(Person person, params PlayedRole[] playedRoles);

        /// <summary>
        /// Deactivates person account
        /// </summary>
        /// <param name="person">Saved person instance</param>
        void Disable(Person person);

        /// <summary>
        /// Activates person account. 
        /// </summary>
        /// <param name="person">Saved person instance</param>
        void Activate(Person person);

        /// <summary>
        /// Activates person and sets password
        /// </summary>
        /// <param name="person">Saved person instance</param>
        /// <param name="password">Person password</param>
        void Activate(Person person, string password);

        /// <summary>
        /// Get person by its unique id
        /// </summary>
        /// <param name="personId">Person unique Id</param>
        /// <returns>Person instance or null if person does not exit</returns>
        Person GetPersonById(int personId);

        /// <summary>
        /// Gets person by its login
        /// </summary>
        /// <param name="login">Person't login</param>
        /// <returns>Person instance or null if login doesnot exist</returns>
        Person GetPersonByLogin(string login);

        /// <summary>
        /// Gets list of all active operators in the system
        /// </summary>
        /// <returns>List of persons</returns>
        IList<Person> GetOperators();

        /// <summary>
        /// Gets list of all active administrators in the system
        /// </summary>
        /// <returns>List of persons</returns>
        IList<Person> GetAdministrators();

        /// <summary>
        /// Gets a list of all active external users in the syste
        /// </summary>
        /// <returns>List of persons</returns>
        IList<Person> GetExternals();

        /// <summary>
        /// Gets a list of active accounts
        /// </summary>
        /// <returns>List of active accounts</returns>
        IList<Person> GetActives();

        /// <summary>
        /// Gets list of people disabled or registered but not activated
        /// </summary>
        /// <returns>List of person instances</returns>
        IList<Person> GetInActives();

        /// <summary>
        /// Gwets list of roles currently played by the given person
        /// </summary>
        /// <param name="person">Saved person account</param>
        /// <returns>Liast of played roles</returns>
        IList<PlayedRole> GetPlayedRoles(Person person);
    }
}
